<?php

namespace app\common\Model;

use think\Model;

class Order extends Model {
	// protected $name = 'transfer';
	/**
	 * 获取订单列表
	 *
	 * @param int $order_id        	订单ID
	 * @return array
	 */
	function getlist($map, $row = 10) {
		$pre = config ( 'database.prefix' );
		return db ( 'transfer t' )->leftJoin ( "{$pre}member mm", "mm.user_id=t.receive_uid" )->leftJoin ( "{$pre}member m", "m.user_id=t.user_id" )->where ( $map )->order ( 'order_id desc' )->field ( 't.*,m.user_name,mm.user_name as receive_username' )->paginate ( $row );
	}
	function getInfo($map = '') {
		$pre = config ( 'database.prefix' );
		return db ( 'transfer t' )->leftJoin ( "{$pre}member mm", "mm.user_id=t.receive_uid" )->leftJoin ( "{$pre}member m", "m.user_id=t.user_id" )->where ( $map )->order ( 'order_id desc' )->field ( 't.*,m.user_name,mm.user_name as receive_username' )->find ();
	}
	function add($data) {
		return db ( 'transfer' )->insertGetId ( $data );
	}
	function edit($map, $data) {
		return db ( 'transfer' )->where ( $map )->update ( $data );
	}
	function del($map) {
		return db ( 'transfer' )->where ( $map )->delete ();
	}
	function getMoney($map) {
		return db ( 'transfer' )->where ( $map )->sum ( 'money' );
	}
}

?>